﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interactivity;
using System.Windows.Media;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Controls.Maps;

namespace TestApp.View.Behaviors
{
    public class MapRectBehaviour : Behavior<Control>
    {
        public static readonly DependencyProperty MapRectProperty =
    DependencyProperty.Register(
        "MapRect",
        typeof(LocationRect),
        typeof(MapRectBehaviour),
        new PropertyMetadata(null, (d, e) =>
        {
            Map map = ((MapRectBehaviour)d).AssociatedObject as Map;
            LocationRect rect = e.NewValue as LocationRect;
            if (rect != null)
            {
                map.SetView(rect);
            }
        }));

        public LocationRect MapRect
        {
            get
            { 
                return (LocationRect)GetValue(MapRectProperty); 
            }
            set 
            { 
                SetValue(MapRectProperty, value);
            }
        }
    }
}
